package com.he.observedmodel.observed.concreteobserved;

import com.he.observedmodel.observed.Observed;
import com.he.observedmodel.subject.Subject;

/**
 * 具体观察者，实现更新接口，保持于与主题状态同步
 */
public class Concreteobserved1 implements Observed {

    private String name;
    private String state;
    private Subject<String> subject;

    public Concreteobserved1(String name, String state, Subject subject) {
        this.name = name;
        this.state = state;
        this.subject = subject;
    }

    @Override
    public void update() {
        this.state = subject.getState();
    }

    @Override
    public String toString() {
        return "Concreteobserved1{" +
                "name='" + name + '\'' +
                ", state='" + state;
    }

}
